<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
	<title>批量操作</title>
	<style type="text/css">
	* {
		padding: 0;
		margin: 0;
	}
    </style>
</head>
<body>
	<div class="container">
		<h1>批量操作</h1>
	</div>
	<script src="php/ajax.js"></script>
	<script type="text/javascript">
	 function query(url, delay = 2000) {
      let promises = [
        //http://localhost:8888/php/user.php?name=后盾人
        ajax(url),
        new Promise((resolve, reject) => {
          setTimeout(() => {
            reject("请求超时");
          }, delay);
        })
      ];
      return Promise.race(promises);
    }
    query(`http://localhost:8888/php/user.php?name=后盾人`, 600)
      .then(value => {
        console.log(value);
      })
      .catch(error => {
        console.log(error);
      });
	</script>
</body>
</html>